﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Common.ORM.Repository;
using FreeRedis;
using sixgod.Model.Attribute;
using sixgod.Model.User;
using SqlSugar;

namespace sixgod.Service.User.Implementation
{
    [Di(typeof(IDepartmentService))]
    public class DepartmentService:Repository<Department>,IDepartmentService
    {
        public DepartmentService(RedisClient redisClient, ISqlSugarClient context) : base(redisClient, context)
        {

        }

        /// <summary>
        /// 获取指定部门领导人
        /// </summary>
        /// <param name="departmentId"></param>
        /// <returns></returns>
        public async Task<Model.User.User> GetDepartmentLeader(string departmentId)
        {
            var department = await Context.Queryable<Department>().Includes(r=>r.DepartmentLeader).FirstAsync(r=>r.Id == departmentId);
            return department.DepartmentLeader;
        }


    }
}
